<?php
/**
 * 描述
 * Created by Paco
 * Date: 2019/1/29 Time: 18:54
 */

namespace App\Http\Request\Shop;


use App\Http\Request\Store;

class ProductStore extends Store
{
    public function rules()
    {
        $method = strtoupper($this->method());
        if ($method == 'POST') {
            return [
                'product_name' => 'required',
                //'base.title' => 'required',
                'list_price' => 'required|integer',
                'brand_id' => 'required|integer',
                'cat_id' => 'required|integer',
                'total_stock' => 'required|integer',
                //'cover_img' => 'required',
                'content' => 'required',
                'disable_spec' => 'required|integer',
                'attrs' => 'filled|array',
                'attrs.*' => 'filled',
                'skus' => 'filled|array',
                'skus.*' => 'filled'
            ];
        } elseif ($method == 'PUT') {
            return [
                'product_id' => 'required',
                'product_name' => 'filled',
                'title' => 'filled',
                'list_price' => 'filled|integer',
                'brand_id' => 'filled|integer',
                'cat_id' => 'filled|integer',
                'total_stock' => 'filled|integer',
                'cover_img' => 'filled',
                'content' => 'filled',
                'disable_spec' => 'filled|integer',
                'attrs' => 'filled|array',
                'attrs.*' => 'filled',
                'skus' => 'filled|array',
                'skus.*' => 'filled'
            ];
        }
    }

    public function attributes()
    {
        return [
            'product_name' => '产品名称',
            'title' => '产品标题',
            'list_price' => '产品价格',
            'brand_id' => '品牌ID',
            'cat_id' => '分类ID',
            'total_stock' => '总库存',
            'cover_img' => '封面图片',
            'content' => '内容',
            'disable_spec' => '开启规格',
        ];
    }
}